/**
 * @author BoLiang
 */
if (typeof accedo === "undefined") {
	accedo = {};
}
if (typeof accedo.achievement === "undefined") {
	accedo.achievement = {};
}

accedo.achievement.achiContShow = {

	oldOnkeydownFunc : null,
	divContCtnNode : null,

	openPage : function(achi_sn) {
		AchiService._path = 'http://127.0.0.1:8080/AchiPlugin/dwr';
		AchiService.getJsonAchiByAchisn(achi_sn, this.openPageCallback);
	},
	openPageCallback : function(data) {
		var serverDataObj = eval("(" + data + ")");
		// create achievement content show container
		accedo.achievement.achiContShow.divContCtnNode = document.createElement("div");
		accedo.achievement.achiContShow.divContCtnNode.id = "divAchiShowContent";
		accedo.achievement.achiContShow.divContCtnNode.innerHTML = "<font size=13px color=white>" + serverDataObj.achi_desc + "</font>";
		var bodyNode = document.getElementsByTagName("body")[0];
		bodyNode.appendChild(accedo.achievement.achiContShow.divContCtnNode);

		accedo.achievement.achiContShow.oldOnkeydownFunc = document.onkeydown;
		document.onkeydown = function(e) {
			accedo.achievement.achiContShow.keysControl(e);
		};
	},
	
	closePage : function() {
		var bodyNode = document.getElementsByTagName("body")[0];
		bodyNode.removeChild(this.divContCtnNode);
		document.onkeydown = this.oldOnkeydownFunc;
	},

	keysControl : function(e) {
		e = window.event || e;
		switch (e.keyCode) {
		// esc button
		case 27:
			this.closePage();
			break;
		default:
			break;
		}
	}

};